// app.js

// 按需导入 $http 对象
import {
    $http
} from './utils/http';

// 将按需导入的 $http 挂载到 wx 顶级对象之上，方便全局调用
wx.$http = $http;

$http.baseUrl = 'http://192.168.8.23:9999';
// $http.baseUrl = 'http://43.136.81.250:9999';

// 请求开始之前做一些事情
$http.beforeRequest = function (options) {
    wx.showLoading({
        title: '数据加载中...',
    })
    console.log('options:', options.url.indexOf('/user/login'));

    if (options.url.indexOf('/user/login') == -1) {
        const token = wx.getStorageSync('token');
        options.header = {
            'Authorization': token,
        }
    }
}

// 请求完成之后做一些事情
$http.afterRequest = function () {
    wx.hideLoading()
}

App({
    onLaunch() {
        const that = this;
        // 展示本地存储能力
        const logs = wx.getStorageSync('logs') || []
        logs.unshift(Date.now())
        wx.setStorageSync('logs', logs)
        console.log('初始化数据')
        const mytikuData = [{
                "id": 1,
                "createTime": "2024-04-06 23:13:54",
                "updateTime": "2024-04-06 23:13:54",
                "isDeleted": false,
                "problem": "是否有入睡困难情况，到睡觉的时间，但是迟迟不想睡呢？",
                "gender": "无",
                "type": "基本问题",
                "selectIndex": 0,
                "index": 1
            },
            {
                "id": 2,
                "createTime": "2024-04-06 23:14:16",
                "updateTime": "2024-04-06 23:14:16",
                "isDeleted": false,
                "problem": "您睡着后会不会容易醒呢，睡不安稳呢？",
                "gender": "无",
                "type": "基本问题",
                "selectIndex": 0,
                "index": 2
            },
            {
                "id": 3,
                "createTime": "2024-04-06 23:15:01",
                "updateTime": "2024-04-06 23:15:01",
                "isDeleted": false,
                "problem": "有没有第二天睡醒时间，比想要醒的时间早呢？",
                "gender": "无",
                "type": "基本问题",
                "selectIndex": 0,
                "index": 3
            },
            {
                "id": 4,
                "createTime": "2024-04-06 23:15:07",
                "updateTime": "2024-04-06 23:15:07",
                "isDeleted": false,
                "problem": "您白天是否容易瞌睡？",
                "gender": "无",
                "type": "基本问题",
                "selectIndex": 0,
                "index": 4
            },
            {
                "id": 5,
                "createTime": "2024-04-06 23:15:13",
                "updateTime": "2024-04-06 23:15:13",
                "isDeleted": false,
                "problem": "白天有没有精神状态不好呢？",
                "gender": "无",
                "type": "基本问题",
                "selectIndex": 0,
                "index": 5
            },
            {
                "id": 6,
                "createTime": "2024-04-06 23:15:19",
                "updateTime": "2024-04-06 23:15:19",
                "isDeleted": false,
                "problem": "有没有觉得注意力、专注力或者记忆力下降呢？",
                "gender": "无",
                "type": "基本问题",
                "selectIndex": 0,
                "index": 6
            },
            {
                "id": 7,
                "createTime": "2024-04-06 23:15:25",
                "updateTime": "2024-04-06 23:15:25",
                "isDeleted": false,
                "problem": "有没有觉得情绪不稳定或者血压增高呢？",
                "gender": "无",
                "type": "基本问题",
                "selectIndex": 0,
                "index": 7
            },
            {
                "id": 8,
                "createTime": "2024-04-06 23:15:30",
                "updateTime": "2024-04-06 23:15:30",
                "isDeleted": false,
                "problem": "是否感觉无缘无故的疲劳呢？",
                "gender": "无",
                "type": "基本问题",
                "selectIndex": 0,
                "index": 8
            },
            {
                "id": 9,
                "createTime": "2024-04-06 23:15:40",
                "updateTime": "2024-04-06 23:15:40",
                "isDeleted": false,
                "problem": "以上问题中如果存在不适情况，出现的频率是怎样的呢？",
                "gender": "无",
                "type": "基本问题",
                "selectIndex": 0,
                "index": 9
            },
            {
                "id": 10,
                "createTime": "2024-04-06 23:15:46",
                "updateTime": "2024-04-06 23:15:46",
                "isDeleted": false,
                "problem": "以上情况持续时间是否超过3个月呢？",
                "gender": "无",
                "type": "基本问题",
                "selectIndex": 0,
                "index": 10
            },
            {
                "id": 11,
                "createTime": "2024-04-06 23:15:51",
                "updateTime": "2024-04-06 23:15:51",
                "isDeleted": false,
                "problem": "在白天，是否稍微动一下，就很容易出虚汗？",
                "gender": "无",
                "type": "心胆气虚证",
                "selectIndex": 0,
                "index": 11
            },
            {
                "id": 12,
                "createTime": "2024-04-06 23:15:57",
                "updateTime": "2024-04-06 23:15:57",
                "isDeleted": false,
                "problem": "在睡觉前，是否感觉心跳很快？",
                "gender": "无",
                "type": "心胆气虚证",
                "selectIndex": 0,
                "index": 12
            },
            {
                "id": 13,
                "createTime": "2024-04-06 23:16:02",
                "updateTime": "2024-04-06 23:16:02",
                "isDeleted": false,
                "problem": "是否容易受到惊吓？",
                "gender": "无",
                "type": "心胆气虚证",
                "selectIndex": 0,
                "index": 13
            },
            {
                "id": 14,
                "createTime": "2024-04-07 00:01:51",
                "updateTime": "2024-04-07 00:02:06",
                "isDeleted": false,
                "problem": "是否容易感到心慌或害怕？",
                "gender": "无",
                "type": "心胆气虚证",
                "selectIndex": 0,
                "index": 14
            },
            {
                "id": 15,
                "createTime": "2024-04-06 23:16:18",
                "updateTime": "2024-04-06 23:16:18",
                "isDeleted": false,
                "problem": "是否觉得口干舌燥或者口苦？",
                "gender": "无",
                "type": "肝火扰心症",
                "selectIndex": 0,
                "index": 15
            },
            {
                "id": 16,
                "createTime": "2024-04-06 23:16:23",
                "updateTime": "2024-04-06 23:16:23",
                "isDeleted": false,
                "problem": "您有尿频、灼热不适感或者排便困难吗？",
                "gender": "无",
                "type": "肝火扰心症",
                "selectIndex": 0,
                "index": 16
            },
            {
                "id": 17,
                "createTime": "2024-04-06 23:16:28",
                "updateTime": "2024-04-06 23:16:28",
                "isDeleted": false,
                "problem": "您是否有眼睛干涩、眼花、红血丝的情况？",
                "gender": "无",
                "type": "肝火扰心症",
                "selectIndex": 0,
                "index": 17
            },
            {
                "id": 18,
                "createTime": "2024-04-06 23:16:33",
                "updateTime": "2024-04-06 23:16:33",
                "isDeleted": false,
                "problem": "是否感到烦躁，有易怒的情况？",
                "gender": "无",
                "type": "肝火扰心症",
                "selectIndex": 0,
                "index": 18
            },
            {
                "id": 19,
                "createTime": "2024-04-06 23:16:38",
                "updateTime": "2024-04-06 23:16:38",
                "isDeleted": false,
                "problem": "您是否觉得痰多，嘴巴里有黏腻感呢？",
                "gender": "无",
                "type": "痰热扰心症",
                "selectIndex": 0,
                "index": 19
            },
            {
                "id": 20,
                "createTime": "2024-04-06 23:16:43",
                "updateTime": "2024-04-06 23:16:43",
                "isDeleted": false,
                "problem": "您是否会咳出黄痰？",
                "gender": "无",
                "type": "痰热扰心症",
                "selectIndex": 0,
                "index": 20
            },
            {
                "id": 21,
                "createTime": "2024-04-06 23:16:48",
                "updateTime": "2024-04-06 23:16:48",
                "isDeleted": false,
                "problem": "您是否经常做噩梦？",
                "gender": "无",
                "type": "痰热扰心症",
                "selectIndex": 0,
                "index": 21
            },
            {
                "id": 22,
                "createTime": "2024-04-06 23:16:53",
                "updateTime": "2024-04-06 23:16:53",
                "isDeleted": false,
                "problem": "有没有觉得脑袋昏昏沉沉呢？",
                "gender": "无",
                "type": "痰热扰心症",
                "selectIndex": 0,
                "index": 22
            },
            {
                "id": 23,
                "createTime": "2024-04-06 23:16:58",
                "updateTime": "2024-04-06 23:16:58",
                "isDeleted": false,
                "problem": "您的失眠是否发生在饮食后？",
                "gender": "无",
                "type": "胃气失和症",
                "selectIndex": 0,
                "index": 23
            },
            {
                "id": 24,
                "createTime": "2024-04-06 23:17:03",
                "updateTime": "2024-04-06 23:17:03",
                "isDeleted": false,
                "problem": "您是否有胃部反酸、恶心想吐的情况？",
                "gender": "无",
                "type": "胃气失和症",
                "selectIndex": 0,
                "index": 24
            },
            {
                "id": 25,
                "createTime": "2024-04-06 23:17:12",
                "updateTime": "2024-04-06 23:17:12",
                "isDeleted": false,
                "problem": "您是否觉得腹部胀满、不舒服？",
                "gender": "无",
                "type": "胃气失和症",
                "selectIndex": 0,
                "index": 25
            },
            {
                "id": 26,
                "createTime": "2024-04-06 23:17:18",
                "updateTime": "2024-04-06 23:17:18",
                "isDeleted": false,
                "problem": "有没有觉得口腔有异味呢？",
                "gender": "无",
                "type": "胃气失和症",
                "selectIndex": 0,
                "index": 26
            },
            {
                "id": 27,
                "createTime": "2024-04-06 23:17:28",
                "updateTime": "2024-04-06 23:17:28",
                "isDeleted": false,
                "problem": "您是否觉得身体某个位置经常有刺痛感？",
                "gender": "无",
                "type": "瘀血内阻症",
                "selectIndex": 0,
                "index": 27
            },
            {
                "id": 28,
                "createTime": "2024-04-06 23:17:34",
                "updateTime": "2024-04-06 23:17:34",
                "isDeleted": false,
                "problem": "您唇色是否比较暗？",
                "gender": "无",
                "type": "瘀血内阻症",
                "selectIndex": 0,
                "index": 28
            },
            {
                "id": 29,
                "createTime": "2024-04-06 23:17:39",
                "updateTime": "2024-04-06 23:17:39",
                "isDeleted": false,
                "problem": "您是否有胸痛或头痛的情况？",
                "gender": "无",
                "type": "瘀血内阻症",
                "selectIndex": 0,
                "index": 29
            },
            {
                "id": 30,
                "createTime": "2024-04-06 23:17:45",
                "updateTime": "2024-04-06 23:17:45",
                "isDeleted": false,
                "problem": "是否感觉烦躁不安？",
                "gender": "男",
                "type": "瘀血内阻症",
                "selectIndex": 0,
                "index": 30
            },
            {
                "id": 31,
                "createTime": "2024-04-06 23:17:51",
                "updateTime": "2024-04-06 23:17:51",
                "isDeleted": false,
                "problem": "您月经期间血块多吗？或者有闭经的情况吗？",
                "gender": "女",
                "type": "瘀血内阻症",
                "selectIndex": 0,
                "index": 30
            },
            {
                "id": 32,
                "createTime": "2024-04-06 23:17:56",
                "updateTime": "2024-04-06 23:17:56",
                "isDeleted": false,
                "problem": "您是否觉得非常疲惫，没有力气？",
                "gender": "无",
                "type": "心脾两虚证",
                "selectIndex": 0,
                "index": 31
            },
            {
                "id": 33,
                "createTime": "2024-04-06 23:18:04",
                "updateTime": "2024-04-06 23:18:04",
                "isDeleted": false,
                "problem": "您是否有健忘的情况？",
                "gender": "无",
                "type": "心脾两虚证",
                "selectIndex": 0,
                "index": 32
            },
            {
                "id": 34,
                "createTime": "2024-04-06 23:18:13",
                "updateTime": "2024-04-06 23:18:13",
                "isDeleted": false,
                "problem": "是否感觉四肢有发冷？",
                "gender": "无",
                "type": "心脾两虚证",
                "selectIndex": 0,
                "index": 33
            },
            {
                "id": 35,
                "createTime": "2024-04-06 23:18:18",
                "updateTime": "2024-04-06 23:18:18",
                "isDeleted": false,
                "problem": "是否有月经量少的情况？",
                "gender": "女",
                "type": "心脾两虚证",
                "selectIndex": 0,
                "index": 34
            },
            {
                "id": 36,
                "createTime": "2024-04-06 23:18:23",
                "updateTime": "2024-04-06 23:18:23",
                "isDeleted": false,
                "problem": "是否觉得乏力？",
                "gender": "男",
                "type": "心脾两虚证",
                "selectIndex": 0,
                "index": 34
            },
            {
                "id": 37,
                "createTime": "2024-04-06 23:18:29",
                "updateTime": "2024-04-06 23:18:29",
                "isDeleted": false,
                "problem": "您是否经常起夜（睡眠时尿多）？",
                "gender": "无",
                "type": "心肾不交症",
                "selectIndex": 0,
                "index": 35
            },
            {
                "id": 38,
                "createTime": "2024-04-06 23:18:36",
                "updateTime": "2024-04-06 23:18:36",
                "isDeleted": false,
                "problem": "您是否有耳鸣的情况？",
                "gender": "无",
                "type": "心肾不交症",
                "selectIndex": 0,
                "index": 36
            },
            {
                "id": 39,
                "createTime": "2024-04-06 23:18:43",
                "updateTime": "2024-04-06 23:18:43",
                "isDeleted": false,
                "problem": "腰部或腿部有酸软的感觉？",
                "gender": "无",
                "type": "心肾不交症",
                "selectIndex": 0,
                "index": 37
            },
            {
                "id": 40,
                "createTime": "2024-04-06 23:18:50",
                "updateTime": "2024-04-06 23:18:50",
                "isDeleted": false,
                "problem": "您最近是否容易掉发或者白发增长较多？",
                "gender": "无",
                "type": "心肾不交症",
                "selectIndex": 0,
                "index": 38
            }
        ]
        const mytikuDataOld = wx.getStorageSync('mytikuData')
        const mytikuData_copy = wx.getStorageSync('mytikuData_copy')
        if (!mytikuDataOld) {
            wx.setStorageSync('mytikuData', mytikuData)
        }
        if (!mytikuData_copy) {
            wx.setStorageSync('mytikuData_copy', mytikuData)
        }
    },
    globalData: {
        userInfo: null,
        isPlay: false,
        token: null,
    }
})